﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DataModel
{
    public class GPS
    {

        ///// <summary>
        ///// GPS方向角
        ///// </summary>
        ////JAVA TO C# CONVERTER NOTE: Fields cannot have the same name as methods:
        //public double GPSHeading_Renamed;

        ///// <summary>
        ///// GPS俯仰角
        ///// </summary>
        ////JAVA TO C# CONVERTER NOTE: Fields cannot have the same name as methods:
        //public double GPSPitch_Renamed;

        ////JAVA TO C# CONVERTER NOTE: Fields cannot have the same name as methods:
        //public long GPSTimestamp_Renamed;

        /// <summary>
        /// 东向坐标
        /// </summary>
        private double x = 0;
        /// <summary>
        /// 北向坐标
        /// </summary>
        private double y = 0;
        /// <summary>
        /// 天向坐标
        /// </summary>
        private double z = 0;


        //private double Height ;
        private double BaseX;
        private double BaseY;
        private double BaseZ;


        public GPS(double baseX, double baseY, double baseZ)
        {
            //this.z = height;
            this.BaseX = baseX;
            this.BaseY = baseY;
            this.BaseZ = baseZ;
        }


        /// <summary>
        /// 时间戳
        /// @return
        /// </summary>
        public long GPSTimestamp;

        public GPS Clone()
        {
            return new GPS(BaseX, BaseY, BaseZ);
        }

        //{
        //    get
        //    {
        //        return GPSTimestamp_Renamed;
        //    }
        //    set
        //    {
        //        GPSTimestamp_Renamed = value;
        //    }
        //}


        //public GPS(double GPSHeading, double GPSPitch, double x, double y, double z)
        //{
        //    this.GPSHeading_Renamed = GPSHeading;
        //    this.GPSPitch_Renamed = GPSPitch;
        //    this.x = x;
        //    this.y = y;
        //    this.z = z;
        //}

        //public GPS(double x, double y, double z, long timestamp)
        //{
        //    this.x = x;
        //    this.y = y;
        //    this.z = z;
        //    GPSTimestamp_Renamed = timestamp;
        //}

        //public GPS(double GPSHeading, double GPSPitch, double x, double y, double z, long timestamp)
        //{
        //    this.GPSHeading_Renamed = GPSHeading;
        //    this.GPSPitch_Renamed = GPSPitch;
        //    this.x = x;
        //    this.y = y;
        //    this.z = z;
        //    GPSTimestamp_Renamed = timestamp;
        //}

        public GPS()
        {
        }
        /// <summary>
        /// 回转角度
        /// </summary>
        public double GPSHeadingAngle { get; set; }
        public double GPSHeadingRadian { get; set; }

        /// <summary>
        /// 回转角度（弧度）
        /// </summary>
        public double ScannerHeadingRadian { get; set; }
        /// <summary>
        /// 扫描仪的回转角度（弧度）
        /// </summary>
        public double ScannerHeadingAngle { get; set; }

        //public double GPSPitch;

        public virtual double X
        {
            get
            {
                return x;
            }
            set
            {
                this.x = value;
            }
        }


        public virtual double Y
        {
            get
            {
                return y;
            }
            set
            {
                this.y = value;
            }
        }


        public virtual double Z
        {
            get
            {
                return z;
            }
            set
            {
                this.z = value;
            }
        }


        //public virtual int CompareTo(GPS o)
        //{
        //    return (int)(this.GPSTimestamp - o.GPSTimestamp);
        //}

        public void ComputeCoordinates(double distanceToCenter, double angleOffset, double height, GPS _gps)
        {
            //在此位置要添加一个ScannerRadian代表实际的扫描仪的角度。
            z = height;
            GPSHeadingAngle = _gps.GPSHeadingAngle;
            GPSHeadingRadian = GPSHeadingAngle * Math.PI / 180;
            ScannerHeadingAngle = GPSHeadingAngle + angleOffset;
            ScannerHeadingRadian = ScannerHeadingAngle / 180 * Math.PI;//此处转换成弧度。
            //GPSPitch = _gps.GPSPitch;
            GPSTimestamp = _gps.GPSTimestamp;
            x = distanceToCenter * Math.Cos(ScannerHeadingRadian) + BaseX;
            y = distanceToCenter * Math.Sin(ScannerHeadingRadian) + BaseY;
        }
    }
}